package cn.sieis.service.student;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.sieis.dao.StudentMapper;
import cn.sieis.pojo.Student;

@Service
public class StudentServiceImpl implements StudentService{
	
	@Autowired
	private StudentMapper studentMapper;

	@Override
	public List<Student> getStudentList(String queryStuName,Integer queryStuSchool,Integer queryStuProject,Integer queryStuContest, Integer currentPageNo,Integer pageSize) throws Exception {
		// TODO Auto-generated method stub
		currentPageNo = (currentPageNo-1)*pageSize;
		return studentMapper.getStudentList(queryStuName,queryStuSchool, queryStuProject,queryStuContest, currentPageNo, pageSize);
	}

	@Override
	public int getStudentCount(String queryStuName,Integer queryStuSchool,Integer queryStuProject,Integer queryStuContest) throws Exception {
		// TODO Auto-generated method stub
		return studentMapper.getStudentCount(queryStuName, queryStuSchool, queryStuProject, queryStuContest);
	}

	@Override
	public boolean addStudent(Student student) throws Exception {
		// TODO Auto-generated method stub
		boolean flag=false;
		if(studentMapper.addStudent(student)>0){
			flag=true;
		}
		return flag;
	}

	@Override
	public boolean modify(Student student) throws Exception {
		// TODO Auto-generated method stub
		boolean flag=false;
		if(studentMapper.modify(student)>0){
			flag=true;
		}
		return flag;
	}

	@Override
	public Student getStudentById(Integer id) throws Exception {
		// TODO Auto-generated method stub
		return studentMapper.getStudentById(id);
	}

	@Override
	public boolean deleteStudentById(Integer id) throws Exception {
		// TODO Auto-generated method stub
		boolean flag=false;
		int i=studentMapper.deleteStudentById(id);
		if(i>0){
			flag=true;
		}else{
			flag=false;
		}
		return flag;
	}

	@Override
	public List<Student> getStuList(String queryStuName,Integer queryStuSchool,Integer queryStuProject,Integer queryStuContest) throws Exception {
		return studentMapper.getStuList(queryStuName, queryStuSchool, queryStuProject, queryStuContest);
	}
	
		@Override
		public boolean register(Student student) {
			boolean flag=false;
			if(studentMapper.register(student)>0){
				flag=true;
			}
			return flag;
		
		}
		
		@Override
		public List<Student> getStudentListFr(String stuName, Integer stuProject) throws Exception {
			return studentMapper.getStudentListFr(stuName, stuProject);
		}

}
